public class Solution693 {
    public boolean hasAlternatingBits(int n) {
        int start=n&1;
        n>>=1;
        while (n>0){
            int t=n&1;
            if (t==start){
                return false;
            }
            start=t;
            n>>=1;
        }
        return true;
    }

    public static void main(String[] args) {
        System.out.println(new Solution693().hasAlternatingBits(5));
    }
}
